package fu.capstone.hanoicityguide.presentation.fragment.transportation;

import java.util.ArrayList;

import fu.capstone.hanoicityguide.R;
import fu.capstone.hanoicityguide.business.bo.taxi.TaxiBO;
import fu.capstone.hanoicityguide.business.bo.taxi.TaxiBOImp;
import fu.capstone.hanoicityguide.business.model.Taxi;
import fu.capstone.hanoicityguide.common.utility.TaxiDialog;
import fu.capstone.hanoicityguide.presentation.adapter.ListTaxiAdapter;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class FragmentTaxiTab extends Fragment {

	private TaxiBO taxiBO;
	private ArrayList<Taxi> arrTaxi;
	private TaxiDialog calldialog;

	@Override
	public View onCreateView(LayoutInflater inflater,
			final ViewGroup container, Bundle savedInstanceState) {
		// TODO Auto-generated method stub

		View taxiTab = inflater.inflate(R.layout.fragment_list_taxi, container,
				false);

		ListView listTaxi = (ListView) taxiTab.findViewById(R.id.listTaxi);
		taxiBO = new TaxiBOImp(container.getContext());

		arrTaxi = new ArrayList<Taxi>();
		arrTaxi = taxiBO.listTaxi("", "");

		listTaxi.setAdapter(new ListTaxiAdapter(getActivity(),
				R.layout.adapter_list_taxi, arrTaxi));

		listTaxi.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// TODO Auto-generated method stub
				calldialog = new TaxiDialog(container.getContext());
				calldialog.showCallDialog(arrTaxi.get(position).getDesc());
			}

		});

		return taxiTab;
	}

}
